<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:sijyp="http://fiscalia.gov/sijyp">

<cc:interface>
	<cc:attribute name="popupId" required="true"
		shortDescription="Identificador del componente flotante (popUp) de rich faces" />
	<cc:attribute name="image" required="false"
		default="/resources/images/icons/warning.png"
		shortDescription="Acceso a la imagen que se muestra en el popUp" />
	<cc:attribute name="cancelLabel" required="false" default="Cancelar"
		shortDescription="Etiqueta para el botón cancelar (opción de rechazo)" />
	<cc:attribute name="acceptLabel" required="false" default="Consultar"
		shortDescription="Etiqueta para el botón aceptar (opción de aceptación)" />
	<cc:attribute name="renderComponents" required="false"
		shortDescription="Componentes a refrescar tras la opción aceptar" />

	<cc:attribute name="personType" required="false" default="natural"
		shortDescription="Tipo persona a mostrar en el componente (diferente campos de busqueda y de tablas)" />
</cc:interface>

<cc:implementation>

	<c:if test="#{sijyp:equals(cc.attrs.personType, 'natural')}">
		<c:set var="header"
			value="${msg['personas.popup.header.consultaNatural']}" />
		<c:set var="include"
			value="searchComponents/personaNaturalContents.xhtml" />
	</c:if>
	<c:if test="#{sijyp:equals(cc.attrs.personType, 'juridica')}">
		<c:set var="header"
			value="${msg['personas.popup.header.consultaJuridica']}" />
		<c:set var="include"
			value="searchComponents/personaJuridicaContents.xhtml" />
	</c:if>
	<c:if test="#{sijyp:equals(cc.attrs.personType, 'colectividad')}">
		<c:set var="header"
			value="${msg['personas.popup.header.consultaColectividad']}" />
		<c:set var="include"
			value="searchComponents/personaColectividadContents.xhtml" />
	</c:if>
	<c:if test="#{sijyp:equals(cc.attrs.personType, 'postulado')}">
		<c:set var="header"
			value="${msg['personas.popup.header.consultaPostulado']}" />
		<c:set var="include" value="searchComponents/postuladoContents.xhtml" />
	</c:if>

	<rich:popupPanel id="#{cc.attrs.popupId}" autosized="true" width="890"
		resizeable="false" styleClass="pop_up_eliminar" modal="true">

		<f:facet name="header">
			<h:outputText id="personasPopUpHeader" value="${header}" />
		</f:facet>
		<h:form id="personasPopUpForm">
			<ui:include src="${include}" />
		</h:form>
	</rich:popupPanel>
	
	<rich:popupPanel id="crearPersonaNaturalPopUpPanel" autosized="true"
		followByScroll="true" modal="true">

		<f:facet name="header">
			<h:outputText value="Registrar Persona Natural" />
		</f:facet>
		<h:form id="crearPersonasPopUpForm">
			<ui:include src="personas/crearPersonaNatural.xhtml" />

			<h:panelGroup style="text-align:center;" layout="block">

				<a4j:commandButton value="Guardar" id="guardarButton" render="personasPanel"
					action="#{personasController.guardar()}" execute="@form"
					oncomplete="if (#{facesContext.validationFailed == false}) { #{rich:component('crearPersonaNaturalPopUpPanel')}.hide(); }" />
				<a4j:commandButton value="Cancelar" id="cancelButton"
					execute="@none"
					onclick="#{rich:component('crearPersonaNaturalPopUpPanel')}.hide();" />
			</h:panelGroup>

		</h:form>
	</rich:popupPanel>
</cc:implementation>
</html>